﻿// ----------------------------------------------------------------
// Description : 实体类,该文件由MyGeneration生成
// Author      : 
// Create date : 2009-12-27
// ----------------------------------------------------------------

using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.Common;
using Microsoft.Practices.EnterpriseLibrary.Data;

namespace ITOMMS.Entity
{
	/// <summary>
	///	tbSupplier Entity
	///	tbSupplier Entity供应商表
	/// </summary>
	[Serializable]
	public class tbSupplierEntity : BaseEntity<tbSupplierEntity,int>
	{
		
		#region 私有成员			
		
		private int _ID; 
		private string _公司名称; 
		private string _编号; 
		private string _电话; 
		private string _传真; 
		private string _负责人; 
		private string _手机; 
		private string _邮政编码; 
		private string _区域; 
		private string _公司地址; 
		private string _开户银行; 
		private string _银行账号; 
		private string _税号; 
		private string _公司经营范围; 
		private string _公司代理产品; 
		private string _备注; 
		private DateTime? _CreateDate; 
		private int? _CreateBy; 
		private DateTime? _ModifyDate; 
		private int? _ModifyBy; 
		private string _QQ; 
		private string _MSN; 
		private string _负责人1; 
		private string _负责人2; 
		private string _负责人手机1; 
		private string _负责人手机2; 
		private string _负责人电话1; 
		private string _负责人电话2; 
		private string _QQ1; 
		private string _QQ2; 
		private string _MSN1; 
		private string _MSN2; 
		private string _邮箱; 
		private string _邮箱1; 
		private string _邮箱2; 
		private int _SEQNO;
		#endregion


		
		#region 默认( 空 ) 构造函数
		/// <summary>
		/// 默认构造函数
		/// </summary>
		public tbSupplierEntity()
		{
			_ID = 0; 
			_公司名称 = String.Empty; 
			_编号 = String.Empty; 
			_电话 = String.Empty; 
			_传真 = String.Empty; 
			_负责人 = String.Empty; 
			_手机 = String.Empty; 
			_邮政编码 = String.Empty; 
			_区域 = String.Empty; 
			_公司地址 = String.Empty; 
			_开户银行 = String.Empty; 
			_银行账号 = String.Empty; 
			_税号 = String.Empty; 
			_公司经营范围 = String.Empty; 
			_公司代理产品 = String.Empty; 
			_备注 = String.Empty; 
			_CreateDate =  null; 
			_CreateBy =  null; 
			_ModifyDate =  null; 
			_ModifyBy =  null; 
			_QQ = String.Empty; 
			_MSN = String.Empty; 
			_负责人1 = String.Empty; 
			_负责人2 = String.Empty; 
			_负责人手机1 = String.Empty; 
			_负责人手机2 = String.Empty; 
			_负责人电话1 = String.Empty; 
			_负责人电话2 = String.Empty; 
			_QQ1 = String.Empty; 
			_QQ2 = String.Empty; 
			_MSN1 = String.Empty; 
			_MSN2 = String.Empty; 
			_邮箱 = String.Empty; 
			_邮箱1 = String.Empty; 
			_邮箱2 = String.Empty; 
			_SEQNO = 0;
		}
		#endregion
		
		#region 属性值校验
		
		/// <summary>
		/// 属性值校验
		/// </summary>
		public bool CheckValues()
		{
			bool bResult = true;
			string strError = "";
		
			if ( _ID ==  0)
			{
				bResult = false;
				strError += "\r\n 非空值不能为: "+_ID;
			}
			
			if( !bResult )
					throw new ArgumentOutOfRangeException(strError);
			return bResult;
			
		}
		
		#endregion
		
		
		
	
		#region Required Fields Only Constructor
		
		/// <summary>
		/// required (not null) fields only constructor
		/// </summary>
		public tbSupplierEntity(
		int para_ID		)
		: this()
		{
					_ID = para_ID;
			_公司名称 = String.Empty;
			_编号 = String.Empty;
			_电话 = String.Empty;
			_传真 = String.Empty;
			_负责人 = String.Empty;
			_手机 = String.Empty;
			_邮政编码 = String.Empty;
			_区域 = String.Empty;
			_公司地址 = String.Empty;
			_开户银行 = String.Empty;
			_银行账号 = String.Empty;
			_税号 = String.Empty;
			_公司经营范围 = String.Empty;
			_公司代理产品 = String.Empty;
			_备注 = String.Empty;
			_CreateDate = null;
			_CreateBy = null;
			_ModifyDate = null;
			_ModifyBy = null;
			_QQ = String.Empty;
			_MSN = String.Empty;
			_负责人1 = String.Empty;
			_负责人2 = String.Empty;
			_负责人手机1 = String.Empty;
			_负责人手机2 = String.Empty;
			_负责人电话1 = String.Empty;
			_负责人电话2 = String.Empty;
			_QQ1 = String.Empty;
			_QQ2 = String.Empty;
			_MSN1 = String.Empty;
			_MSN2 = String.Empty;
			_邮箱 = String.Empty;
			_邮箱1 = String.Empty;
			_邮箱2 = String.Empty;
		}
		#endregion 

		
		#region 公有属性
			
			/// <summary>
			/// 行号，顺序号。系统默认的属性,对这个属性不要作操作.属性值在架构中已经处理
			/// </summary>
			public virtual int SEQNO
			{
				get { return _SEQNO; }
				set { _SEQNO = value; }
			}
		
			
		/// <summary>
		/// IDID
		/// </summary>		
		public virtual int ID
		{
			get { return _ID; }
			set { _ID = value; }
		}
			
		/// <summary>
		/// 公司名称公司名称
		/// </summary>		
		public virtual string 公司名称
		{
			get { return _公司名称; }
			set	
			{
				
				if ( value != null)
					if( value.Length > 50)
						throw new ArgumentOutOfRangeException("Invalid value for 公司名称", value, value.ToString());
				
				_公司名称 = value;
			}
		}
			
		/// <summary>
		/// 编号编号
		/// </summary>		
		public virtual string 编号
		{
			get { return _编号; }
			set	
			{
				
				if ( value != null)
					if( value.Length > 50)
						throw new ArgumentOutOfRangeException("Invalid value for 编号", value, value.ToString());
				
				_编号 = value;
			}
		}
			
		/// <summary>
		/// 电话电话
		/// </summary>		
		public virtual string 电话
		{
			get { return _电话; }
			set	
			{
				
				if ( value != null)
					if( value.Length > 50)
						throw new ArgumentOutOfRangeException("Invalid value for 电话", value, value.ToString());
				
				_电话 = value;
			}
		}
			
		/// <summary>
		/// 传真传真
		/// </summary>		
		public virtual string 传真
		{
			get { return _传真; }
			set	
			{
				
				if ( value != null)
					if( value.Length > 50)
						throw new ArgumentOutOfRangeException("Invalid value for 传真", value, value.ToString());
				
				_传真 = value;
			}
		}
			
		/// <summary>
		/// 负责人负责人
		/// </summary>		
		public virtual string 负责人
		{
			get { return _负责人; }
			set	
			{
				
				if ( value != null)
					if( value.Length > 50)
						throw new ArgumentOutOfRangeException("Invalid value for 负责人", value, value.ToString());
				
				_负责人 = value;
			}
		}
			
		/// <summary>
		/// 手机手机
		/// </summary>		
		public virtual string 手机
		{
			get { return _手机; }
			set	
			{
				
				if ( value != null)
					if( value.Length > 50)
						throw new ArgumentOutOfRangeException("Invalid value for 手机", value, value.ToString());
				
				_手机 = value;
			}
		}
			
		/// <summary>
		/// 邮政编码邮政编码
		/// </summary>		
		public virtual string 邮政编码
		{
			get { return _邮政编码; }
			set	
			{
				
				if ( value != null)
					if( value.Length > 50)
						throw new ArgumentOutOfRangeException("Invalid value for 邮政编码", value, value.ToString());
				
				_邮政编码 = value;
			}
		}
			
		/// <summary>
		/// 区域区域
		/// </summary>		
		public virtual string 区域
		{
			get { return _区域; }
			set	
			{
				
				if ( value != null)
					if( value.Length > 50)
						throw new ArgumentOutOfRangeException("Invalid value for 区域", value, value.ToString());
				
				_区域 = value;
			}
		}
			
		/// <summary>
		/// 公司地址公司地址
		/// </summary>		
		public virtual string 公司地址
		{
			get { return _公司地址; }
			set	
			{
				
				if ( value != null)
					if( value.Length > 50)
						throw new ArgumentOutOfRangeException("Invalid value for 公司地址", value, value.ToString());
				
				_公司地址 = value;
			}
		}
			
		/// <summary>
		/// 开户银行开户银行
		/// </summary>		
		public virtual string 开户银行
		{
			get { return _开户银行; }
			set	
			{
				
				if ( value != null)
					if( value.Length > 50)
						throw new ArgumentOutOfRangeException("Invalid value for 开户银行", value, value.ToString());
				
				_开户银行 = value;
			}
		}
			
		/// <summary>
		/// 银行账号银行账号
		/// </summary>		
		public virtual string 银行账号
		{
			get { return _银行账号; }
			set	
			{
				
				if ( value != null)
					if( value.Length > 50)
						throw new ArgumentOutOfRangeException("Invalid value for 银行账号", value, value.ToString());
				
				_银行账号 = value;
			}
		}
			
		/// <summary>
		/// 税号税号
		/// </summary>		
		public virtual string 税号
		{
			get { return _税号; }
			set	
			{
				
				if ( value != null)
					if( value.Length > 50)
						throw new ArgumentOutOfRangeException("Invalid value for 税号", value, value.ToString());
				
				_税号 = value;
			}
		}
			
		/// <summary>
		/// 公司经营范围公司经营范围
		/// </summary>		
		public virtual string 公司经营范围
		{
			get { return _公司经营范围; }
			set	
			{
				
				if ( value != null)
					if( value.Length > 50)
						throw new ArgumentOutOfRangeException("Invalid value for 公司经营范围", value, value.ToString());
				
				_公司经营范围 = value;
			}
		}
			
		/// <summary>
		/// 公司代理产品公司代理产品
		/// </summary>		
		public virtual string 公司代理产品
		{
			get { return _公司代理产品; }
			set	
			{
				
				if ( value != null)
					if( value.Length > 50)
						throw new ArgumentOutOfRangeException("Invalid value for 公司代理产品", value, value.ToString());
				
				_公司代理产品 = value;
			}
		}
			
		/// <summary>
		/// 备注备注
		/// </summary>		
		public virtual string 备注
		{
			get { return _备注; }
			set	
			{
				
				if ( value != null)
					if( value.Length > 500)
						throw new ArgumentOutOfRangeException("Invalid value for 备注", value, value.ToString());
				
				_备注 = value;
			}
		}
			
		/// <summary>
		/// CreateDate创建时间
		/// </summary>		
		public virtual DateTime? CreateDate
		{
			get { return _CreateDate; }
			set { _CreateDate = value; }
		}
			
		/// <summary>
		/// CreateBy创建人
		/// </summary>		
		public virtual int? CreateBy
		{
			get { return _CreateBy; }
			set { _CreateBy = value; }
		}
			
		/// <summary>
		/// ModifyDate修改时间
		/// </summary>		
		public virtual DateTime? ModifyDate
		{
			get { return _ModifyDate; }
			set { _ModifyDate = value; }
		}
			
		/// <summary>
		/// ModifyBy修改人
		/// </summary>		
		public virtual int? ModifyBy
		{
			get { return _ModifyBy; }
			set { _ModifyBy = value; }
		}
			
		/// <summary>
		/// QQ
		/// </summary>		
		public virtual string QQ
		{
			get { return _QQ; }
			set	
			{
				
				if ( value != null)
					if( value.Length > 20)
						throw new ArgumentOutOfRangeException("Invalid value for QQ", value, value.ToString());
				
				_QQ = value;
			}
		}
			
		/// <summary>
		/// MSN
		/// </summary>		
		public virtual string MSN
		{
			get { return _MSN; }
			set	
			{
				
				if ( value != null)
					if( value.Length > 20)
						throw new ArgumentOutOfRangeException("Invalid value for MSN", value, value.ToString());
				
				_MSN = value;
			}
		}
			
		/// <summary>
		/// 负责人1
		/// </summary>		
		public virtual string 负责人1
		{
			get { return _负责人1; }
			set	
			{
				
				if ( value != null)
					if( value.Length > 30)
						throw new ArgumentOutOfRangeException("Invalid value for 负责人1", value, value.ToString());
				
				_负责人1 = value;
			}
		}
			
		/// <summary>
		/// 负责人2
		/// </summary>		
		public virtual string 负责人2
		{
			get { return _负责人2; }
			set	
			{
				
				if ( value != null)
					if( value.Length > 30)
						throw new ArgumentOutOfRangeException("Invalid value for 负责人2", value, value.ToString());
				
				_负责人2 = value;
			}
		}
			
		/// <summary>
		/// 负责人手机1
		/// </summary>		
		public virtual string 负责人手机1
		{
			get { return _负责人手机1; }
			set	
			{
				
				if ( value != null)
					if( value.Length > 30)
						throw new ArgumentOutOfRangeException("Invalid value for 负责人手机1", value, value.ToString());
				
				_负责人手机1 = value;
			}
		}
			
		/// <summary>
		/// 负责人手机2
		/// </summary>		
		public virtual string 负责人手机2
		{
			get { return _负责人手机2; }
			set	
			{
				
				if ( value != null)
					if( value.Length > 30)
						throw new ArgumentOutOfRangeException("Invalid value for 负责人手机2", value, value.ToString());
				
				_负责人手机2 = value;
			}
		}
			
		/// <summary>
		/// 负责人电话1
		/// </summary>		
		public virtual string 负责人电话1
		{
			get { return _负责人电话1; }
			set	
			{
				
				if ( value != null)
					if( value.Length > 30)
						throw new ArgumentOutOfRangeException("Invalid value for 负责人电话1", value, value.ToString());
				
				_负责人电话1 = value;
			}
		}
			
		/// <summary>
		/// 负责人电话2
		/// </summary>		
		public virtual string 负责人电话2
		{
			get { return _负责人电话2; }
			set	
			{
				
				if ( value != null)
					if( value.Length > 30)
						throw new ArgumentOutOfRangeException("Invalid value for 负责人电话2", value, value.ToString());
				
				_负责人电话2 = value;
			}
		}
			
		/// <summary>
		/// QQ1
		/// </summary>		
		public virtual string QQ1
		{
			get { return _QQ1; }
			set	
			{
				
				if ( value != null)
					if( value.Length > 30)
						throw new ArgumentOutOfRangeException("Invalid value for QQ1", value, value.ToString());
				
				_QQ1 = value;
			}
		}
			
		/// <summary>
		/// QQ2
		/// </summary>		
		public virtual string QQ2
		{
			get { return _QQ2; }
			set	
			{
				
				if ( value != null)
					if( value.Length > 30)
						throw new ArgumentOutOfRangeException("Invalid value for QQ2", value, value.ToString());
				
				_QQ2 = value;
			}
		}
			
		/// <summary>
		/// MSN1
		/// </summary>		
		public virtual string MSN1
		{
			get { return _MSN1; }
			set	
			{
				
				if ( value != null)
					if( value.Length > 30)
						throw new ArgumentOutOfRangeException("Invalid value for MSN1", value, value.ToString());
				
				_MSN1 = value;
			}
		}
			
		/// <summary>
		/// MSN2
		/// </summary>		
		public virtual string MSN2
		{
			get { return _MSN2; }
			set	
			{
				
				if ( value != null)
					if( value.Length > 30)
						throw new ArgumentOutOfRangeException("Invalid value for MSN2", value, value.ToString());
				
				_MSN2 = value;
			}
		}
			
		/// <summary>
		/// 邮箱
		/// </summary>		
		public virtual string 邮箱
		{
			get { return _邮箱; }
			set	
			{
				
				if ( value != null)
					if( value.Length > 30)
						throw new ArgumentOutOfRangeException("Invalid value for 邮箱", value, value.ToString());
				
				_邮箱 = value;
			}
		}
			
		/// <summary>
		/// 邮箱1
		/// </summary>		
		public virtual string 邮箱1
		{
			get { return _邮箱1; }
			set	
			{
				
				if ( value != null)
					if( value.Length > 30)
						throw new ArgumentOutOfRangeException("Invalid value for 邮箱1", value, value.ToString());
				
				_邮箱1 = value;
			}
		}
			
		/// <summary>
		/// 邮箱2
		/// </summary>		
		public virtual string 邮箱2
		{
			get { return _邮箱2; }
			set	
			{
				
				if ( value != null)
					if( value.Length > 30)
						throw new ArgumentOutOfRangeException("Invalid value for 邮箱2", value, value.ToString());
				
				_邮箱2 = value;
			}
		}
			


		#endregion 	
		
		
        #region DAO操作
		
		
		/// <summary>
        /// 获取所有实体的列表
        /// </summary>
        /// <returns></returns>
        public override List<tbSupplierEntity> GetAll()
        {
            StringBuilder strSql = new StringBuilder();
			strSql.Append("select [ID],[公司名称],[编号],[电话],[传真],[负责人],[手机],[邮政编码],[区域],[公司地址],[开户银行],[银行账号],[税号],[公司经营范围],[公司代理产品],[备注],[CreateDate],[CreateBy],[ModifyDate],[ModifyBy],[QQ],[MSN],[负责人1],[负责人2],[负责人手机1],[负责人手机2],[负责人电话1],[负责人电话2],[QQ1],[QQ2],[MSN1],[MSN2],[邮箱],[邮箱1],[邮箱2] from [tb_Supplier] ");
	
            List<tbSupplierEntity> list = new List<tbSupplierEntity>();
            Database db = GetDatabase();
            using (IDataReader dataReader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
            {
				int seq = 0;
                while (dataReader.Read())
                {	seq++;
                    list.Add(ReaderBind(dataReader,seq));
                }
            }
            return list;
        }
		
		/// <summary>
        /// 获取所有实体的列表总行数
        /// </summary>
        /// <returns></returns>
        public override int GetTotalRecords()
        {
            StringBuilder strSql = new StringBuilder();
			strSql.Append("  select count([ID])  from [tb_Supplier] ");
	
            Database db = GetDatabase();
            return (int)db.ExecuteScalar(CommandType.Text, strSql.ToString());
        }
		
		/// <summary>
        /// 获取所有实体的列表总行数
        /// </summary>
        /// <returns></returns>
        public override int GetTotalRecords(string sqlCondition)
        {
            StringBuilder strSql = new StringBuilder();
			strSql.Append("  select count([ID])  from [tb_Supplier]  ");
	
			 if (sqlCondition.Trim() != "")
            {
                strSql.Append(" where " + sqlCondition);
            }
            Database db = GetDatabase();
            return (int)db.ExecuteScalar(CommandType.Text, strSql.ToString());
        }	
		
		
		/// <summary>
        /// 按条件查询,得到一页的对应的结果列表
        /// </summary>
        /// <param name="strWhere">条件</param>
		/// <param name="PageSize">每页大小</param>
		/// <param name="CurrentPageIndex">当前页码</param>
        /// <returns></returns>
		 public override List<tbSupplierEntity> GetAllByQuery(string strWhere, int PageSize, int CurrentPageIndex)
        {
            StringBuilder strSql = new StringBuilder();
            if (strWhere.Contains("order".ToLower()))
            {
                throw new Exception("分页查询的sql条件中不能包括排序子句，请调用重载方法实现有条件的排序筛选");
            }
		 
			strSql.Append("select top ").Append(PageSize).Append("  [ID],[公司名称],[编号],[电话],[传真],[负责人],[手机],[邮政编码],[区域],[公司地址],[开户银行],[银行账号],[税号],[公司经营范围],[公司代理产品],[备注],[CreateDate],[CreateBy],[ModifyDate],[ModifyBy],[QQ],[MSN],[负责人1],[负责人2],[负责人手机1],[负责人手机2],[负责人电话1],[负责人电话2],[QQ1],[QQ2],[MSN1],[MSN2],[邮箱],[邮箱1],[邮箱2] from [tb_Supplier] where ");

			 if (strWhere.Trim() != "")
            {
                strSql.Append("  " + strWhere + " and ");
            }
			  strSql.Append(" ID not in ( ");
			 strSql.Append(" select top ").Append(PageSize*(CurrentPageIndex-1)).Append("  [ID] from [tb_Supplier] ");

            if (strWhere.Trim() != "")
            {
                strSql.Append(" where " + strWhere );
            }
			strSql.Append(" ) " );

            List<tbSupplierEntity> list = new List<tbSupplierEntity>();
            Database db = GetDatabase();
            using (IDataReader dataReader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
            {
			   int seq = PageSize * (CurrentPageIndex - 1);
                while (dataReader.Read())
                {
					seq++;
                    list.Add(ReaderBind(dataReader, seq));
                }
            }
            return list;
        }
		
		
			/// <summary>
        /// 按条件查询,得到一页的对应的结果列表
        /// </summary>
        /// <param name="strWhere">条件</param>
		/// <param name="PageSize">每页大小</param>
		/// <param name="CurrentPageIndex">当前页码</param>
		/// <param name="strSort">ex:order by id desc</param>
        /// <returns></returns>
		 public override List<tbSupplierEntity> GetAllByQuery(string strWhere,string strSort, int PageSize, int CurrentPageIndex)
        {
            StringBuilder strSql = new StringBuilder();
            if (strWhere.Contains("order".ToLower()))
            {
                throw new Exception("分页查询的sql条件中不能包括排序子句，请调用重载方法实现有条件的排序筛选");
            }
		 
			strSql.Append("select top ").Append(PageSize).Append("  [ID],[公司名称],[编号],[电话],[传真],[负责人],[手机],[邮政编码],[区域],[公司地址],[开户银行],[银行账号],[税号],[公司经营范围],[公司代理产品],[备注],[CreateDate],[CreateBy],[ModifyDate],[ModifyBy],[QQ],[MSN],[负责人1],[负责人2],[负责人手机1],[负责人手机2],[负责人电话1],[负责人电话2],[QQ1],[QQ2],[MSN1],[MSN2],[邮箱],[邮箱1],[邮箱2] from [tb_Supplier] where ");

			 if (strWhere.Trim() != "")
            {
                strSql.Append("  " + strWhere + " and ");
            }
			  strSql.Append(" ID not in ( ");
			 strSql.Append(" select top ").Append(PageSize*(CurrentPageIndex-1)).Append("  [ID] from [tb_Supplier] ");

            if (strWhere.Trim() != "")
            {
                strSql.Append(" where " + strWhere+" " ).Append(strSort);
            }
			strSql.Append(" ) " ).Append(strSort);

            List<tbSupplierEntity> list = new List<tbSupplierEntity>();
            Database db = GetDatabase();
            using (IDataReader dataReader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
            {
				int seq = PageSize * (CurrentPageIndex - 1);
                while (dataReader.Read())
                {	
					seq++;
                    list.Add(ReaderBind(dataReader, seq));
                }
            }
            return list;
        }
		
		
		/// <summary>
        /// 按条件查询,得到对应的结果列表
        /// </summary>
        /// <param name="strWhere"></param>
        /// <returns></returns>
        public override List<tbSupplierEntity> GetAllByQuery(string strWhere)
        {
			strWhere = SQLInjectionFilter(strWhere);
            StringBuilder strSql = new StringBuilder();
			strSql.Append("select [ID],[公司名称],[编号],[电话],[传真],[负责人],[手机],[邮政编码],[区域],[公司地址],[开户银行],[银行账号],[税号],[公司经营范围],[公司代理产品],[备注],[CreateDate],[CreateBy],[ModifyDate],[ModifyBy],[QQ],[MSN],[负责人1],[负责人2],[负责人手机1],[负责人手机2],[负责人电话1],[负责人电话2],[QQ1],[QQ2],[MSN1],[MSN2],[邮箱],[邮箱1],[邮箱2] from tb_Supplier ");

            if (strWhere.Trim() != "")
            {
                strSql.Append(" where " + strWhere);
            }
            List<tbSupplierEntity> list = new List<tbSupplierEntity>();
            Database db = GetDatabase();
            using (IDataReader dataReader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
            { 
				int seq = 0;
                while (dataReader.Read())
                {
					seq++;
                    list.Add(ReaderBind(dataReader,seq));
                }
            }
            return list;
        }
		
		
		
		/// <summary>
        /// 按条件查询,得到对应的结果列表
        /// </summary>
        /// <param name="strWhere"></param>
		/// <param name="parameters">sql条件中的参数</param>
        /// <returns></returns>
        public override List<tbSupplierEntity> GetAllByQuery(string strWhere, List<IDataParameter> parameters)
        {
            StringBuilder strSql = new StringBuilder();
			strSql.Append("select [ID],[公司名称],[编号],[电话],[传真],[负责人],[手机],[邮政编码],[区域],[公司地址],[开户银行],[银行账号],[税号],[公司经营范围],[公司代理产品],[备注],[CreateDate],[CreateBy],[ModifyDate],[ModifyBy],[QQ],[MSN],[负责人1],[负责人2],[负责人手机1],[负责人手机2],[负责人电话1],[负责人电话2],[QQ1],[QQ2],[MSN1],[MSN2],[邮箱],[邮箱1],[邮箱2] from [tb_Supplier] ");

            if (strWhere.Trim() != "")
            {
                strSql.Append(" where " + strWhere);
            }
            List<tbSupplierEntity> list = new List<tbSupplierEntity>();
            Database db = GetDatabase();
            DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString());
            foreach (IDataParameter sp in parameters)
            {
                db.AddInParameter(dbCommand, sp.ParameterName, sp.DbType, sp.Value);
            }

            using (IDataReader dataReader = db.ExecuteReader(dbCommand))
            {
				int seq =0 ;
                while (dataReader.Read())
                {
					seq++;
                    list.Add(ReaderBind(dataReader,seq));
                }
            }
            return list;
        }
		
		
		

		
		
		/// <summary>
        /// 获取按条件查询以后的结果列表的前指定rowNumber行记录
        /// </summary>
        /// <param name="strWhere">不带where关键字的SQL条件语句</param>
        /// <param name="rowNumber"></param>
        /// <returns></returns>
        public override List<tbSupplierEntity> GetAllByQuery(string strWhere, List<IDataParameter> parameters, int rowNumber)
        {

            StringBuilder strSql = new StringBuilder();
			strSql.Append("select top ").Append(rowNumber).Append("  [ID],[公司名称],[编号],[电话],[传真],[负责人],[手机],[邮政编码],[区域],[公司地址],[开户银行],[银行账号],[税号],[公司经营范围],[公司代理产品],[备注],[CreateDate],[CreateBy],[ModifyDate],[ModifyBy],[QQ],[MSN],[负责人1],[负责人2],[负责人手机1],[负责人手机2],[负责人电话1],[负责人电话2],[QQ1],[QQ2],[MSN1],[MSN2],[邮箱],[邮箱1],[邮箱2] from [tb_Supplier] ");

            if (strWhere.Trim() != "")
            {
                strSql.Append(" where " + strWhere);
            }
            List<tbSupplierEntity> list = new List<tbSupplierEntity>();
            Database db = GetDatabase();
            DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString());
            foreach (IDataParameter sp in parameters)
            {
                db.AddInParameter(dbCommand, sp.ParameterName, sp.DbType, sp.Value);
            }

            using (IDataReader dataReader = db.ExecuteReader(dbCommand))
            {	
				int seq = 0;
                while (dataReader.Read())
                {
					seq++;
                    list.Add(ReaderBind(dataReader,seq));
                }
            }
            return list;
        }
		
		
		/// <summary>
        /// 获取按条件查询以后的结果列表的前指定rowNumber行记录
        /// </summary>
        /// <param name="strWhere">不带where关键字的SQL条件语句: AND AA=@AA</param>
        /// <param name="rowNumber"></param>
        /// <returns></returns>
        public override List<tbSupplierEntity> GetAllByQuery(string strWhere, int rowNumber)
        {
		    strWhere = SQLInjectionFilter(strWhere);
            StringBuilder strSql = new StringBuilder();
			
			strSql.Append("select top ").Append(rowNumber).Append("  [ID],[公司名称],[编号],[电话],[传真],[负责人],[手机],[邮政编码],[区域],[公司地址],[开户银行],[银行账号],[税号],[公司经营范围],[公司代理产品],[备注],[CreateDate],[CreateBy],[ModifyDate],[ModifyBy],[QQ],[MSN],[负责人1],[负责人2],[负责人手机1],[负责人手机2],[负责人电话1],[负责人电话2],[QQ1],[QQ2],[MSN1],[MSN2],[邮箱],[邮箱1],[邮箱2] from [tb_Supplier] ");

            if (strWhere.Trim() != "")
            {
                strSql.Append(" where  " + strWhere);
            }
            List<tbSupplierEntity> list = new List<tbSupplierEntity>();
            Database db = GetDatabase();
            using (IDataReader dataReader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
            {
				int seq=0;
                while (dataReader.Read())
                {	
					seq++;
                    list.Add(ReaderBind(dataReader,seq));
                }
            }
            return list;
        }
		
		
		
		
		
		
		
        /// <summary>
        /// 按主键查询对应的实体
        /// </summary>
        /// <param name="id">主键ID</param>
        /// <returns></returns>
        public override tbSupplierEntity GetById(int id)
        {
            StringBuilder strSql = new StringBuilder();
			strSql.Append("select [ID],[公司名称],[编号],[电话],[传真],[负责人],[手机],[邮政编码],[区域],[公司地址],[开户银行],[银行账号],[税号],[公司经营范围],[公司代理产品],[备注],[CreateDate],[CreateBy],[ModifyDate],[ModifyBy],[QQ],[MSN],[负责人1],[负责人2],[负责人手机1],[负责人手机2],[负责人电话1],[负责人电话2],[QQ1],[QQ2],[MSN1],[MSN2],[邮箱],[邮箱1],[邮箱2] from [tb_Supplier]  where ID= @ID ");
				
            Database db = GetDatabase();
            DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString());
            db.AddInParameter(dbCommand, "ID", DbType.Int32, id);
            tbSupplierEntity entity = null;
            using (IDataReader dataReader = db.ExecuteReader(dbCommand))
            {
                if (dataReader.Read())
                {
                    entity = ReaderBind(dataReader);
                }
            }
            return entity;

        }
		
		
		 /// <summary>
        /// 保存实体
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public override int Save()
        {
			
            if (this.ID ==0)
            {
                this.ID = GetMax("tb_Supplier");
            }
            StringBuilder strSql = new StringBuilder();
			strSql.Append("insert into  tb_Supplier (");
			strSql.Append("[ID],[公司名称],[编号],[电话],[传真],[负责人],[手机],[邮政编码],[区域],[公司地址],[开户银行],[银行账号],[税号],[公司经营范围],[公司代理产品],[备注],[CreateDate],[CreateBy],[ModifyDate],[ModifyBy],[QQ],[MSN],[负责人1],[负责人2],[负责人手机1],[负责人手机2],[负责人电话1],[负责人电话2],[QQ1],[QQ2],[MSN1],[MSN2],[邮箱],[邮箱1],[邮箱2] )");
			strSql.Append(" values (");
			strSql.Append("@ID,@公司名称,@编号,@电话,@传真,@负责人,@手机,@邮政编码,@区域,@公司地址,@开户银行,@银行账号,@税号,@公司经营范围,@公司代理产品,@备注,@CreateDate,@CreateBy,@ModifyDate,@ModifyBy,@QQ,@MSN,@负责人1,@负责人2,@负责人手机1,@负责人手机2,@负责人电话1,@负责人电话2,@QQ1,@QQ2,@MSN1,@MSN2,@邮箱,@邮箱1,@邮箱2)");

            Database db = GetDatabase();
            DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString());
			db.AddInParameter(dbCommand, "ID", DbType.Int32, this.ID);
			db.AddInParameter(dbCommand, "公司名称", DbType.String, this.公司名称);
			db.AddInParameter(dbCommand, "编号", DbType.String, this.编号);
			db.AddInParameter(dbCommand, "电话", DbType.String, this.电话);
			db.AddInParameter(dbCommand, "传真", DbType.String, this.传真);
			db.AddInParameter(dbCommand, "负责人", DbType.String, this.负责人);
			db.AddInParameter(dbCommand, "手机", DbType.String, this.手机);
			db.AddInParameter(dbCommand, "邮政编码", DbType.String, this.邮政编码);
			db.AddInParameter(dbCommand, "区域", DbType.String, this.区域);
			db.AddInParameter(dbCommand, "公司地址", DbType.String, this.公司地址);
			db.AddInParameter(dbCommand, "开户银行", DbType.String, this.开户银行);
			db.AddInParameter(dbCommand, "银行账号", DbType.String, this.银行账号);
			db.AddInParameter(dbCommand, "税号", DbType.String, this.税号);
			db.AddInParameter(dbCommand, "公司经营范围", DbType.String, this.公司经营范围);
			db.AddInParameter(dbCommand, "公司代理产品", DbType.String, this.公司代理产品);
			db.AddInParameter(dbCommand, "备注", DbType.String, this.备注);
			if (this.CreateDate == null)
			{
			db.AddInParameter(dbCommand, "CreateDate", DbType.DateTime, System.DBNull.Value);
			}
			else
			{
			db.AddInParameter(dbCommand, "CreateDate", DbType.DateTime, this.CreateDate.Value);
			}
			if (this.CreateBy == null)
			{
			db.AddInParameter(dbCommand, "CreateBy", DbType.Int32, System.DBNull.Value);
			}
			else
			{
			db.AddInParameter(dbCommand, "CreateBy", DbType.Int32, this.CreateBy.Value);
			}
			if (this.ModifyDate == null)
			{
			db.AddInParameter(dbCommand, "ModifyDate", DbType.DateTime, System.DBNull.Value);
			}
			else
			{
			db.AddInParameter(dbCommand, "ModifyDate", DbType.DateTime, this.ModifyDate.Value);
			}
			if (this.ModifyBy == null)
			{
			db.AddInParameter(dbCommand, "ModifyBy", DbType.Int32, System.DBNull.Value);
			}
			else
			{
			db.AddInParameter(dbCommand, "ModifyBy", DbType.Int32, this.ModifyBy.Value);
			}
			db.AddInParameter(dbCommand, "QQ", DbType.String, this.QQ);
			db.AddInParameter(dbCommand, "MSN", DbType.String, this.MSN);
			db.AddInParameter(dbCommand, "负责人1", DbType.String, this.负责人1);
			db.AddInParameter(dbCommand, "负责人2", DbType.String, this.负责人2);
			db.AddInParameter(dbCommand, "负责人手机1", DbType.String, this.负责人手机1);
			db.AddInParameter(dbCommand, "负责人手机2", DbType.String, this.负责人手机2);
			db.AddInParameter(dbCommand, "负责人电话1", DbType.String, this.负责人电话1);
			db.AddInParameter(dbCommand, "负责人电话2", DbType.String, this.负责人电话2);
			db.AddInParameter(dbCommand, "QQ1", DbType.String, this.QQ1);
			db.AddInParameter(dbCommand, "QQ2", DbType.String, this.QQ2);
			db.AddInParameter(dbCommand, "MSN1", DbType.String, this.MSN1);
			db.AddInParameter(dbCommand, "MSN2", DbType.String, this.MSN2);
			db.AddInParameter(dbCommand, "邮箱", DbType.String, this.邮箱);
			db.AddInParameter(dbCommand, "邮箱1", DbType.String, this.邮箱1);
			db.AddInParameter(dbCommand, "邮箱2", DbType.String, this.邮箱2);

			return db.ExecuteNonQuery(dbCommand);
		  
      
        }
		

		
        /// <summary>
        /// 保存实体
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public override int Save(tbSupplierEntity entity)
        {
			
            if (entity.ID == 0)
            {
                entity.ID = GetMax("tb_Supplier");
            }
            StringBuilder strSql = new StringBuilder();
			strSql.Append("insert into  tb_Supplier (");
			strSql.Append("[ID],[公司名称],[编号],[电话],[传真],[负责人],[手机],[邮政编码],[区域],[公司地址],[开户银行],[银行账号],[税号],[公司经营范围],[公司代理产品],[备注],[CreateDate],[CreateBy],[ModifyDate],[ModifyBy],[QQ],[MSN],[负责人1],[负责人2],[负责人手机1],[负责人手机2],[负责人电话1],[负责人电话2],[QQ1],[QQ2],[MSN1],[MSN2],[邮箱],[邮箱1],[邮箱2] )");
			strSql.Append(" values (");
			strSql.Append("@ID,@公司名称,@编号,@电话,@传真,@负责人,@手机,@邮政编码,@区域,@公司地址,@开户银行,@银行账号,@税号,@公司经营范围,@公司代理产品,@备注,@CreateDate,@CreateBy,@ModifyDate,@ModifyBy,@QQ,@MSN,@负责人1,@负责人2,@负责人手机1,@负责人手机2,@负责人电话1,@负责人电话2,@QQ1,@QQ2,@MSN1,@MSN2,@邮箱,@邮箱1,@邮箱2)");

            Database db = GetDatabase();
            DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString());
			db.AddInParameter(dbCommand, "ID", DbType.Int32, entity.ID);
			db.AddInParameter(dbCommand, "公司名称", DbType.String, entity.公司名称);
			db.AddInParameter(dbCommand, "编号", DbType.String, entity.编号);
			db.AddInParameter(dbCommand, "电话", DbType.String, entity.电话);
			db.AddInParameter(dbCommand, "传真", DbType.String, entity.传真);
			db.AddInParameter(dbCommand, "负责人", DbType.String, entity.负责人);
			db.AddInParameter(dbCommand, "手机", DbType.String, entity.手机);
			db.AddInParameter(dbCommand, "邮政编码", DbType.String, entity.邮政编码);
			db.AddInParameter(dbCommand, "区域", DbType.String, entity.区域);
			db.AddInParameter(dbCommand, "公司地址", DbType.String, entity.公司地址);
			db.AddInParameter(dbCommand, "开户银行", DbType.String, entity.开户银行);
			db.AddInParameter(dbCommand, "银行账号", DbType.String, entity.银行账号);
			db.AddInParameter(dbCommand, "税号", DbType.String, entity.税号);
			db.AddInParameter(dbCommand, "公司经营范围", DbType.String, entity.公司经营范围);
			db.AddInParameter(dbCommand, "公司代理产品", DbType.String, entity.公司代理产品);
			db.AddInParameter(dbCommand, "备注", DbType.String, entity.备注);
			if (entity.CreateDate == null)
			{
			db.AddInParameter(dbCommand, "CreateDate", DbType.DateTime, System.DBNull.Value);
			}
			else
			{
			db.AddInParameter(dbCommand, "CreateDate", DbType.DateTime, entity.CreateDate.Value);
			}
			if (entity.CreateBy == null)
			{
			db.AddInParameter(dbCommand, "CreateBy", DbType.Int32, System.DBNull.Value);
			}
			else
			{
			db.AddInParameter(dbCommand, "CreateBy", DbType.Int32, entity.CreateBy.Value);
			}
			if (entity.ModifyDate == null)
			{
			db.AddInParameter(dbCommand, "ModifyDate", DbType.DateTime, System.DBNull.Value);
			}
			else
			{
			db.AddInParameter(dbCommand, "ModifyDate", DbType.DateTime, entity.ModifyDate.Value);
			}
			if (entity.ModifyBy == null)
			{
			db.AddInParameter(dbCommand, "ModifyBy", DbType.Int32, System.DBNull.Value);
			}
			else
			{
			db.AddInParameter(dbCommand, "ModifyBy", DbType.Int32, entity.ModifyBy.Value);
			}
			db.AddInParameter(dbCommand, "QQ", DbType.String, entity.QQ);
			db.AddInParameter(dbCommand, "MSN", DbType.String, entity.MSN);
			db.AddInParameter(dbCommand, "负责人1", DbType.String, entity.负责人1);
			db.AddInParameter(dbCommand, "负责人2", DbType.String, entity.负责人2);
			db.AddInParameter(dbCommand, "负责人手机1", DbType.String, entity.负责人手机1);
			db.AddInParameter(dbCommand, "负责人手机2", DbType.String, entity.负责人手机2);
			db.AddInParameter(dbCommand, "负责人电话1", DbType.String, entity.负责人电话1);
			db.AddInParameter(dbCommand, "负责人电话2", DbType.String, entity.负责人电话2);
			db.AddInParameter(dbCommand, "QQ1", DbType.String, entity.QQ1);
			db.AddInParameter(dbCommand, "QQ2", DbType.String, entity.QQ2);
			db.AddInParameter(dbCommand, "MSN1", DbType.String, entity.MSN1);
			db.AddInParameter(dbCommand, "MSN2", DbType.String, entity.MSN2);
			db.AddInParameter(dbCommand, "邮箱", DbType.String, entity.邮箱);
			db.AddInParameter(dbCommand, "邮箱1", DbType.String, entity.邮箱1);
			db.AddInParameter(dbCommand, "邮箱2", DbType.String, entity.邮箱2);

			return db.ExecuteNonQuery(dbCommand);
		  
      
        }
		
		
        /// <summary>
        /// 保存或者更新(如果传入的实体主键为空则保存,否则做更新操作)
        /// </summary>
        /// <param name="entity">传入的实体</param>
        /// <returns>影响的行数</returns>
        public override int SaveOrUpdate(tbSupplierEntity entity)
        {
			
            if (entity.ID  == 0)
            {
                if (Save(entity)>0)
                {
                    return 1;
                }
                else
                {
                    return 0;
                }
            }
            else
            {
                return Update(entity);
            }
        }
		
		/// <summary>
        /// 保存或者更新(如果传入的实体主键为空则保存,否则做更新操作)
        /// </summary>
        /// <param name="entity">传入的实体</param>
        /// <returns>影响的行数</returns>
        public override int SaveOrUpdate()
        {
		
            if (this.ID  == 0)
            {
                if (Save()>0)
                {
                    return 1;
                }
                else
                {
                    return 0;
                }
            }
            else
            {
                return Update();
            }
        }
		
		/// <summary>
        /// 是否存在对应主键ID的记录
        /// </summary>
        /// <param name="ID"></param>
        /// <returns></returns>
        public override bool IsExist(int ID)
        {
            Database db = GetDatabase();
            StringBuilder strSql = new StringBuilder();
            			 strSql.Append("select count(1) from tb_Supplier where ID=@ID ");

            DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString());
            db.AddInParameter(dbCommand, "ID", DbType.Int32, ID);//这里为ID是因为原有代码把主键都变成了ID.
            int cmdresult;
            object obj = db.ExecuteScalar(dbCommand);
            if ((Object.Equals(obj, null)) || (Object.Equals(obj, System.DBNull.Value)))
            {
                cmdresult = 0;
            }
            else
            {
                cmdresult = int.Parse(obj.ToString());
            }
            if (cmdresult == 0)
            {
                return false;
            }
            else
            {
                return true;
            }
        }
		
		
		/// <summary>
        /// 删除对应的实体
        /// </summary>
        /// <param name="entity"></param>
        public override int Delete(tbSupplierEntity entity)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("delete tb_Supplier ");
            strSql.Append(" where ID=@ID ");
            Database db = GetDatabase();
            DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString());
            db.AddInParameter(dbCommand, "ID", DbType.Int32, entity.ID );
            return db.ExecuteNonQuery(dbCommand);
        }
		
		/// <summary>
        /// 删除主键ID对应的记录
        /// </summary>
        /// <param name="id"></param>
        public override int Delete(int id)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("delete tb_Supplier ");
            strSql.Append(" where ID=@ID ");
            Database db = GetDatabase();
            DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString());
            db.AddInParameter(dbCommand, "ID", DbType.Int32, id);
            return db.ExecuteNonQuery(dbCommand);
        }
		
		
		/// <summary>
		/// 更新一条数据
		/// </summary>
		public override int Update()
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("update tb_Supplier set ");
			strSql.Append("[ID]=@ID,[公司名称]=@公司名称,[编号]=@编号,[电话]=@电话,[传真]=@传真,[负责人]=@负责人,[手机]=@手机,[邮政编码]=@邮政编码,[区域]=@区域,[公司地址]=@公司地址,[开户银行]=@开户银行,[银行账号]=@银行账号,[税号]=@税号,[公司经营范围]=@公司经营范围,[公司代理产品]=@公司代理产品,[备注]=@备注,[CreateDate]=@CreateDate,[CreateBy]=@CreateBy,[ModifyDate]=@ModifyDate,[ModifyBy]=@ModifyBy,[QQ]=@QQ,[MSN]=@MSN,[负责人1]=@负责人1,[负责人2]=@负责人2,[负责人手机1]=@负责人手机1,[负责人手机2]=@负责人手机2,[负责人电话1]=@负责人电话1,[负责人电话2]=@负责人电话2,[QQ1]=@QQ1,[QQ2]=@QQ2,[MSN1]=@MSN1,[MSN2]=@MSN2,[邮箱]=@邮箱,[邮箱1]=@邮箱1,[邮箱2]=@邮箱2 ");

            strSql.Append(" where ID=@ID ");
            Database db = GetDatabase();
			DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString());
			db.AddInParameter(dbCommand, "ID", DbType.Int32, this.ID );
			db.AddInParameter(dbCommand, "公司名称", DbType.String, this.公司名称);
			db.AddInParameter(dbCommand, "编号", DbType.String, this.编号);
			db.AddInParameter(dbCommand, "电话", DbType.String, this.电话);
			db.AddInParameter(dbCommand, "传真", DbType.String, this.传真);
			db.AddInParameter(dbCommand, "负责人", DbType.String, this.负责人);
			db.AddInParameter(dbCommand, "手机", DbType.String, this.手机);
			db.AddInParameter(dbCommand, "邮政编码", DbType.String, this.邮政编码);
			db.AddInParameter(dbCommand, "区域", DbType.String, this.区域);
			db.AddInParameter(dbCommand, "公司地址", DbType.String, this.公司地址);
			db.AddInParameter(dbCommand, "开户银行", DbType.String, this.开户银行);
			db.AddInParameter(dbCommand, "银行账号", DbType.String, this.银行账号);
			db.AddInParameter(dbCommand, "税号", DbType.String, this.税号);
			db.AddInParameter(dbCommand, "公司经营范围", DbType.String, this.公司经营范围);
			db.AddInParameter(dbCommand, "公司代理产品", DbType.String, this.公司代理产品);
			db.AddInParameter(dbCommand, "备注", DbType.String, this.备注);
			if (this.CreateDate == null)
			{
			db.AddInParameter(dbCommand, "CreateDate", DbType.DateTime, System.DBNull.Value);
			}
			else
			{
			db.AddInParameter(dbCommand, "CreateDate", DbType.DateTime, this.CreateDate.Value);
			}
			if (this.CreateBy == null)
			{
			db.AddInParameter(dbCommand, "CreateBy", DbType.Int32, System.DBNull.Value);
			}
			else
			{
			db.AddInParameter(dbCommand, "CreateBy", DbType.Int32, this.CreateBy.Value);
			}
			if (this.ModifyDate == null)
			{
			db.AddInParameter(dbCommand, "ModifyDate", DbType.DateTime, System.DBNull.Value);
			}
			else
			{
			db.AddInParameter(dbCommand, "ModifyDate", DbType.DateTime, this.ModifyDate.Value);
			}
			if (this.ModifyBy == null)
			{
			db.AddInParameter(dbCommand, "ModifyBy", DbType.Int32, System.DBNull.Value);
			}
			else
			{
			db.AddInParameter(dbCommand, "ModifyBy", DbType.Int32, this.ModifyBy.Value);
			}
			db.AddInParameter(dbCommand, "QQ", DbType.String, this.QQ);
			db.AddInParameter(dbCommand, "MSN", DbType.String, this.MSN);
			db.AddInParameter(dbCommand, "负责人1", DbType.String, this.负责人1);
			db.AddInParameter(dbCommand, "负责人2", DbType.String, this.负责人2);
			db.AddInParameter(dbCommand, "负责人手机1", DbType.String, this.负责人手机1);
			db.AddInParameter(dbCommand, "负责人手机2", DbType.String, this.负责人手机2);
			db.AddInParameter(dbCommand, "负责人电话1", DbType.String, this.负责人电话1);
			db.AddInParameter(dbCommand, "负责人电话2", DbType.String, this.负责人电话2);
			db.AddInParameter(dbCommand, "QQ1", DbType.String, this.QQ1);
			db.AddInParameter(dbCommand, "QQ2", DbType.String, this.QQ2);
			db.AddInParameter(dbCommand, "MSN1", DbType.String, this.MSN1);
			db.AddInParameter(dbCommand, "MSN2", DbType.String, this.MSN2);
			db.AddInParameter(dbCommand, "邮箱", DbType.String, this.邮箱);
			db.AddInParameter(dbCommand, "邮箱1", DbType.String, this.邮箱1);
			db.AddInParameter(dbCommand, "邮箱2", DbType.String, this.邮箱2);

			
			return	db.ExecuteNonQuery(dbCommand);

		}
		



		
		/// <summary>
		/// 更新一条数据
		/// </summary>
		public override int Update(tbSupplierEntity entity)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("update tb_Supplier set ");
			strSql.Append("[ID]=@ID,[公司名称]=@公司名称,[编号]=@编号,[电话]=@电话,[传真]=@传真,[负责人]=@负责人,[手机]=@手机,[邮政编码]=@邮政编码,[区域]=@区域,[公司地址]=@公司地址,[开户银行]=@开户银行,[银行账号]=@银行账号,[税号]=@税号,[公司经营范围]=@公司经营范围,[公司代理产品]=@公司代理产品,[备注]=@备注,[CreateDate]=@CreateDate,[CreateBy]=@CreateBy,[ModifyDate]=@ModifyDate,[ModifyBy]=@ModifyBy,[QQ]=@QQ,[MSN]=@MSN,[负责人1]=@负责人1,[负责人2]=@负责人2,[负责人手机1]=@负责人手机1,[负责人手机2]=@负责人手机2,[负责人电话1]=@负责人电话1,[负责人电话2]=@负责人电话2,[QQ1]=@QQ1,[QQ2]=@QQ2,[MSN1]=@MSN1,[MSN2]=@MSN2,[邮箱]=@邮箱,[邮箱1]=@邮箱1,[邮箱2]=@邮箱2 ");

            strSql.Append(" where ID=@ID ");
            Database db = GetDatabase();
			DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString());
			db.AddInParameter(dbCommand, "ID", DbType.Int32, entity.ID );
			db.AddInParameter(dbCommand, "公司名称", DbType.String, entity.公司名称);
			db.AddInParameter(dbCommand, "编号", DbType.String, entity.编号);
			db.AddInParameter(dbCommand, "电话", DbType.String, entity.电话);
			db.AddInParameter(dbCommand, "传真", DbType.String, entity.传真);
			db.AddInParameter(dbCommand, "负责人", DbType.String, entity.负责人);
			db.AddInParameter(dbCommand, "手机", DbType.String, entity.手机);
			db.AddInParameter(dbCommand, "邮政编码", DbType.String, entity.邮政编码);
			db.AddInParameter(dbCommand, "区域", DbType.String, entity.区域);
			db.AddInParameter(dbCommand, "公司地址", DbType.String, entity.公司地址);
			db.AddInParameter(dbCommand, "开户银行", DbType.String, entity.开户银行);
			db.AddInParameter(dbCommand, "银行账号", DbType.String, entity.银行账号);
			db.AddInParameter(dbCommand, "税号", DbType.String, entity.税号);
			db.AddInParameter(dbCommand, "公司经营范围", DbType.String, entity.公司经营范围);
			db.AddInParameter(dbCommand, "公司代理产品", DbType.String, entity.公司代理产品);
			db.AddInParameter(dbCommand, "备注", DbType.String, entity.备注);
			if (entity.CreateDate == null)
			{
			db.AddInParameter(dbCommand, "CreateDate", DbType.DateTime, System.DBNull.Value);
			}
			else
			{
			db.AddInParameter(dbCommand, "CreateDate", DbType.DateTime, entity.CreateDate.Value);
			}
			if (entity.CreateBy == null)
			{
			db.AddInParameter(dbCommand, "CreateBy", DbType.Int32, System.DBNull.Value);
			}
			else
			{
			db.AddInParameter(dbCommand, "CreateBy", DbType.Int32, entity.CreateBy.Value);
			}
			if (entity.ModifyDate == null)
			{
			db.AddInParameter(dbCommand, "ModifyDate", DbType.DateTime, System.DBNull.Value);
			}
			else
			{
			db.AddInParameter(dbCommand, "ModifyDate", DbType.DateTime, entity.ModifyDate.Value);
			}
			if (entity.ModifyBy == null)
			{
			db.AddInParameter(dbCommand, "ModifyBy", DbType.Int32, System.DBNull.Value);
			}
			else
			{
			db.AddInParameter(dbCommand, "ModifyBy", DbType.Int32, entity.ModifyBy.Value);
			}
			db.AddInParameter(dbCommand, "QQ", DbType.String, entity.QQ);
			db.AddInParameter(dbCommand, "MSN", DbType.String, entity.MSN);
			db.AddInParameter(dbCommand, "负责人1", DbType.String, entity.负责人1);
			db.AddInParameter(dbCommand, "负责人2", DbType.String, entity.负责人2);
			db.AddInParameter(dbCommand, "负责人手机1", DbType.String, entity.负责人手机1);
			db.AddInParameter(dbCommand, "负责人手机2", DbType.String, entity.负责人手机2);
			db.AddInParameter(dbCommand, "负责人电话1", DbType.String, entity.负责人电话1);
			db.AddInParameter(dbCommand, "负责人电话2", DbType.String, entity.负责人电话2);
			db.AddInParameter(dbCommand, "QQ1", DbType.String, entity.QQ1);
			db.AddInParameter(dbCommand, "QQ2", DbType.String, entity.QQ2);
			db.AddInParameter(dbCommand, "MSN1", DbType.String, entity.MSN1);
			db.AddInParameter(dbCommand, "MSN2", DbType.String, entity.MSN2);
			db.AddInParameter(dbCommand, "邮箱", DbType.String, entity.邮箱);
			db.AddInParameter(dbCommand, "邮箱1", DbType.String, entity.邮箱1);
			db.AddInParameter(dbCommand, "邮箱2", DbType.String, entity.邮箱2);

			
			return	db.ExecuteNonQuery(dbCommand);

		}
		


		
		
		
		
		/// <summary>
        /// 对象实体绑定数据
		///生成构造为list的构造器
        /// </summary>
        private tbSupplierEntity ReaderBind(IDataReader dataReader,int seq)
        {
            ITOMMS.Entity.tbSupplierEntity entity = new ITOMMS.Entity.tbSupplierEntity();
			entity.SEQNO = seq;
            object obj;
			obj = dataReader["ID"];
			 if (obj != null && obj != DBNull.Value)
			 {
			 entity.ID = (int)obj;
			 }
			 entity.公司名称= dataReader["公司名称"].ToString();
			 entity.编号= dataReader["编号"].ToString();
			 entity.电话= dataReader["电话"].ToString();
			 entity.传真= dataReader["传真"].ToString();
			 entity.负责人= dataReader["负责人"].ToString();
			 entity.手机= dataReader["手机"].ToString();
			 entity.邮政编码= dataReader["邮政编码"].ToString();
			 entity.区域= dataReader["区域"].ToString();
			 entity.公司地址= dataReader["公司地址"].ToString();
			 entity.开户银行= dataReader["开户银行"].ToString();
			 entity.银行账号= dataReader["银行账号"].ToString();
			 entity.税号= dataReader["税号"].ToString();
			 entity.公司经营范围= dataReader["公司经营范围"].ToString();
			 entity.公司代理产品= dataReader["公司代理产品"].ToString();
			 entity.备注= dataReader["备注"].ToString();
			 obj=dataReader["CreateDate"];
			if(obj != null && obj != DBNull.Value)
			{
			 entity.CreateDate= (DateTime)obj;
			}
			 obj=dataReader["CreateBy"];
			if(obj != null && obj != DBNull.Value)
			{
			 entity.CreateBy= (int)obj;
			}
			 obj=dataReader["ModifyDate"];
			if(obj != null && obj != DBNull.Value)
			{
			 entity.ModifyDate= (DateTime)obj;
			}
			 obj=dataReader["ModifyBy"];
			if(obj != null && obj != DBNull.Value)
			{
			 entity.ModifyBy= (int)obj;
			}
			 entity.QQ= dataReader["QQ"].ToString();
			 entity.MSN= dataReader["MSN"].ToString();
			 entity.负责人1= dataReader["负责人1"].ToString();
			 entity.负责人2= dataReader["负责人2"].ToString();
			 entity.负责人手机1= dataReader["负责人手机1"].ToString();
			 entity.负责人手机2= dataReader["负责人手机2"].ToString();
			 entity.负责人电话1= dataReader["负责人电话1"].ToString();
			 entity.负责人电话2= dataReader["负责人电话2"].ToString();
			 entity.QQ1= dataReader["QQ1"].ToString();
			 entity.QQ2= dataReader["QQ2"].ToString();
			 entity.MSN1= dataReader["MSN1"].ToString();
			 entity.MSN2= dataReader["MSN2"].ToString();
			 entity.邮箱= dataReader["邮箱"].ToString();
			 entity.邮箱1= dataReader["邮箱1"].ToString();
			 entity.邮箱2= dataReader["邮箱2"].ToString();

            return entity;
        }
		
		
				/// <summary>
        /// 对象实体绑定数据
		///生成构造为list的构造器
        /// </summary>
        private tbSupplierEntity ReaderBind(IDataReader dataReader)
        {
            ITOMMS.Entity.tbSupplierEntity entity = new ITOMMS.Entity.tbSupplierEntity();
			object obj;
			obj = dataReader["ID"];
			 if (obj != null && obj != DBNull.Value)
			 {
			 entity.ID = (int)obj;
			 }
			 entity.公司名称= dataReader["公司名称"].ToString();
			 entity.编号= dataReader["编号"].ToString();
			 entity.电话= dataReader["电话"].ToString();
			 entity.传真= dataReader["传真"].ToString();
			 entity.负责人= dataReader["负责人"].ToString();
			 entity.手机= dataReader["手机"].ToString();
			 entity.邮政编码= dataReader["邮政编码"].ToString();
			 entity.区域= dataReader["区域"].ToString();
			 entity.公司地址= dataReader["公司地址"].ToString();
			 entity.开户银行= dataReader["开户银行"].ToString();
			 entity.银行账号= dataReader["银行账号"].ToString();
			 entity.税号= dataReader["税号"].ToString();
			 entity.公司经营范围= dataReader["公司经营范围"].ToString();
			 entity.公司代理产品= dataReader["公司代理产品"].ToString();
			 entity.备注= dataReader["备注"].ToString();
			 obj=dataReader["CreateDate"];
			if(obj != null && obj != DBNull.Value)
			{
			 entity.CreateDate= (DateTime)obj;
			}
			 obj=dataReader["CreateBy"];
			if(obj != null && obj != DBNull.Value)
			{
			 entity.CreateBy= (int)obj;
			}
			 obj=dataReader["ModifyDate"];
			if(obj != null && obj != DBNull.Value)
			{
			 entity.ModifyDate= (DateTime)obj;
			}
			 obj=dataReader["ModifyBy"];
			if(obj != null && obj != DBNull.Value)
			{
			 entity.ModifyBy= (int)obj;
			}
			 entity.QQ= dataReader["QQ"].ToString();
			 entity.MSN= dataReader["MSN"].ToString();
			 entity.负责人1= dataReader["负责人1"].ToString();
			 entity.负责人2= dataReader["负责人2"].ToString();
			 entity.负责人手机1= dataReader["负责人手机1"].ToString();
			 entity.负责人手机2= dataReader["负责人手机2"].ToString();
			 entity.负责人电话1= dataReader["负责人电话1"].ToString();
			 entity.负责人电话2= dataReader["负责人电话2"].ToString();
			 entity.QQ1= dataReader["QQ1"].ToString();
			 entity.QQ2= dataReader["QQ2"].ToString();
			 entity.MSN1= dataReader["MSN1"].ToString();
			 entity.MSN2= dataReader["MSN2"].ToString();
			 entity.邮箱= dataReader["邮箱"].ToString();
			 entity.邮箱1= dataReader["邮箱1"].ToString();
			 entity.邮箱2= dataReader["邮箱2"].ToString();

            return entity;
        }
		
		
		
		 #endregion
		
	}
}
